package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShopOperationManual;
import com.ruoyi.system.service.IShopOperationManualService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 操作指南Controller
 * 
 * @author ruoyi
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/system/manual")
public class ShopOperationManualController extends BaseController
{
    @Autowired
    private IShopOperationManualService shopOperationManualService;

    /**
     * 查询操作指南列表
     */
    @PreAuthorize("@ss.hasPermi('system:manual:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopOperationManual shopOperationManual)
    {
        startPage();
        List<ShopOperationManual> list = shopOperationManualService.selectShopOperationManualList(shopOperationManual);
        return getDataTable(list);
    }

    /**
     * 导出操作指南列表
     */
    @PreAuthorize("@ss.hasPermi('system:manual:export')")
    @Log(title = "操作指南", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopOperationManual shopOperationManual)
    {
        List<ShopOperationManual> list = shopOperationManualService.selectShopOperationManualList(shopOperationManual);
        ExcelUtil<ShopOperationManual> util = new ExcelUtil<ShopOperationManual>(ShopOperationManual.class);
        util.exportExcel(response, list, "操作指南数据");
    }

    /**
     * 获取操作指南详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:manual:query')")
    @GetMapping(value = "/{operationId}")
    public AjaxResult getInfo(@PathVariable("operationId") Long operationId)
    {
        return success(shopOperationManualService.selectShopOperationManualByOperationId(operationId));
    }

    /**
     * 新增操作指南
     */
    @PreAuthorize("@ss.hasPermi('system:manual:add')")
    @Log(title = "操作指南", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopOperationManual shopOperationManual)
    {
        return toAjax(shopOperationManualService.insertShopOperationManual(shopOperationManual));
    }

    /**
     * 修改操作指南
     */
    @PreAuthorize("@ss.hasPermi('system:manual:edit')")
    @Log(title = "操作指南", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopOperationManual shopOperationManual)
    {
        return toAjax(shopOperationManualService.updateShopOperationManual(shopOperationManual));
    }

    /**
     * 删除操作指南
     */
    @PreAuthorize("@ss.hasPermi('system:manual:remove')")
    @Log(title = "操作指南", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operationIds}")
    public AjaxResult remove(@PathVariable Long[] operationIds)
    {
        return toAjax(shopOperationManualService.deleteShopOperationManualByOperationIds(operationIds));
    }
}
